package com.zhiche.lisa.bms.controller.psup;

import com.zhiche.lisa.core.enums.CommonEnum;
import com.zhiche.lisa.core.supports.RestfulResponse;

import java.util.List;

/**
 * @author: linbao
 * @date: 2019-06-18
 */
public class PsupSdBaseController {

    /**
     * 成功返回的数据格式
     *
     * @return
     */
    public RestfulResponse getSuccessResponse() {
        return new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(), null);
    }

    /**
     * 返回错误信息的
     *
     * @param baseExceptionMsg
     * @return
     */
    public void setBaseExceptionResponse(RestfulResponse restfulResponse, String baseExceptionMsg) {
        restfulResponse.setCode(CommonEnum.ERROR.getCode());
        restfulResponse.setMessage(baseExceptionMsg);
    }

    /**
     * 返回异常的数据格式
     *
     * @return
     */
    public void setErrorResponse(RestfulResponse restfulResponse) {
        restfulResponse.setCode(CommonEnum.ERROR.getCode());
        restfulResponse.setMessage(CommonEnum.ERROR.getText());
    }

    /**
     * 返回异常的数据格式
     *
     * @return
     */
    public void setErrorListResponse(RestfulResponse restfulResponse, List<String> errorMsgList) {
        restfulResponse.setCode(CommonEnum.ERRORLIST.getCode());
        restfulResponse.setMessage(CommonEnum.ERROR.getText());
        restfulResponse.setData(errorMsgList);
    }
}
